<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE html>
<html>

<head>
    <base href="${pageContext.request.contextPath}/"/>
    <title>襄阳蓝芯智能化办公系统</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <style>
        /*定义类名为.thead-blue的样式*/
        .thead-blue {
            color: #fff;
            font-weight: bold;
            background-color: #337ab7;
        }
    </style>
    <link rel="stylesheet" type="text/css" href="view/bootstrap-3.3.5/css/bootstrap.css"/>
    <link rel="stylesheet" type="text/css" href="view/bootstrapvalidator/css/bootstrapValidator.css"/>
    <script charset="utf-8" src="view/jquery/jquery-1.10.2.min.js"></script>
    <script charset="utf-8" src="view/bootstrap-3.3.5/js/bootstrap.js"></script>
    <script charset="utf-8" src="view/bootstrapvalidator/js/bootstrapValidator.js"></script>
</head>
<body>
<!-- 搜索 -->
<div class="panel panel-primary">
    <div class="panel-heading">
        <h4 class="panel-title">员工调动搜索</h4>
    </div>
    <div class="panel-body">
        <form action="adjust/adjustmentInfo" id="seachform" method="post" class="form-horizontal" role="form">
            <c:if test='${all==null || all==""}'>
                <div class="form-group">
                    <div class="col-md-4">
                        <label for="startDate" class="col-md-4 control-label">开始时间</label>
                        <div class="col-md-8">
                            <input type="hidden" name="page" id="page" value="${pageBean.page }">
                            <input type="hidden" name="pageSize" id="pageSize" value="${pageBean.pageSize }">
                            <input type="hidden" name="empid" value="${requestScope.empid}">
                            <input type="date" id="startDate" name="startDate" class="form-control"
                                   value="<fmt:formatDate value='${startDate}' pattern='yyyy-MM-dd'/>">
                        </div>
                    </div>
                    <div class="col-md-4">
                        <label for="endDate" class="col-md-4 control-label">结束时间</label>
                        <div class="col-md-8">
                            <input type="date" id="endDate" name="endDate" class="form-control"
                                   value="<fmt:formatDate value='${endDate}' pattern='yyyy-MM-dd'/>">
                        </div>
                    </div>
                    <div class="col-md-4">
                        <div class="col-md-12">
                            <button type="submit" class="btn btn-success">搜索调动记录</button>
                            <a type="button" href="javascript:history.back()" class="btn btn-info">返回</a>
                        </div>
                    </div>
                </div>
            </c:if>
            <c:if test='${all!=null && all!=""}'>
                <div class="form-group">
                    <div class="col-md-4">
                        <label for="startDate" class="col-md-4 control-label">开始时间</label>
                        <div class="col-md-8">
                            <input type="hidden" name="page" id="page" value="${pageBean.page }">
                            <input type="hidden" name="pageSize" id="pageSize" value="${pageBean.pageSize }">
                            <input type="date" id="startDate" name="startDate" class="form-control"
                                   value="<fmt:formatDate value='${startDate}' pattern='yyyy-MM-dd'/>">
                        </div>
                    </div>
                    <div class="col-md-4">
                        <label for="endDate" class="col-md-4 control-label">结束时间</label>
                        <div class="col-md-8">
                            <input type="date" id="endDate" name="endDate" class="form-control"
                                   value="<fmt:formatDate value='${endDate}' pattern='yyyy-MM-dd'/>">
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-md-4">
                        <label for="empName" class="col-md-4 control-label">搜索员工</label>
                        <div class="col-md-8">
                            <input type="hidden" id="empid" name="empid" value="${empid }">
                            <input type="hidden" name="all" value="searchall">
                            <div class="input-group">
                                <input type="text" id="empName" name="empName"
                                       readonly="readonly" class="form-control" placeholder="请选择员工"
                                       value="${empName}"> <span
                                    class="input-group-btn">
										<button class="btn btn-info" type="button"
                                                data-toggle="modal" data-target="#selectempModal">请选择</button>
									</span>
                            </div>
                        </div>
                    </div>
                    <div class="col-md-4">
                        <div class="col-md-12 col-md-offset-4">
                            <button type="submit" class="btn btn-success">搜索调动记录</button>
                            <button type="button" onclick="clearSearch()" class="btn btn-default">清空搜索条件</button>
                        </div>
                    </div>
                </div>
            </c:if>
        </form>
    </div>
</div>

<!-- 列表 -->
<div class="panel panel-primary">
    <table class="table table-bordered table-hover">
        <thead>
        <tr class="thead-blue" align="center">
            <td>员工姓名</td>
            <td>调动前部门</td>
            <td>调动前职位</td>
            <td>调动后部门</td>
            <td>调动后职位</td>
            <td>调动时间</td>
            <td>调动原因</td>
        </tr>
        </thead>
        <tbody>
        <c:forEach items="${pageBean.data }" var="adjustment">
            <tr align="center">
                <td>${adjustment.emp.empName }</td>
                <td>${adjustment.dept.deptName}</td>
                <td>${adjustment.basic.name}</td>
                <td>${adjustment.department.deptName}</td>
                <td>${adjustment.basicdatavalue.name }</td>
                <td>
                    <fmt:formatDate value="${adjustment.adjustDate }" pattern="yyyy-MM-dd HH:mm:ss"/>
                </td>
                <td>${adjustment.reason}</td>
            </tr>
        </c:forEach>
        </tbody>
    </table>
</div>

<!-- 分页 -->
<div class="input-group col-md-6 col-md-offset-3">
    <div class="row">
        <div class="btn-group">
            <button onclick="gotoPage(1,${pageBean.pageSize})" class="btn btn-primary" type="button">首页</button>
            <c:if test="${pageBean.page==1 }">
                <button class="btn btn-primary disabled" type="button">上一页</button>
            </c:if>
            <c:if test="${pageBean.page>1 }">
                <button onclick="gotoPage(${pageBean.page-1},${pageBean.pageSize})" class="btn btn-primary"
                        type="button">上一页
                </button>
            </c:if>

            <button class="btn btn-primary disabled" type="button">当前第${pageBean.page}/${pageBean.pageCount}页</button>

            <div class="btn-group">
                <button type="button" class="btn btn-primary dropdown-toggle"
                        data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                    每页显示${pageBean.pageSize}条 <span class="caret"></span>
                </button>
                <ul class="dropdown-menu">
                    <li><a href="javascript:gotoPage(1,5)">每页显示5条</a></li>
                    <li><a href="javascript:gotoPage(1,10)">每页显示10条</a></li>
                    <li><a href="javascript:gotoPage(1,15)">每页显示15条</a></li>
                    <li><a href="javascript:gotoPage(1,20)">每页显示20条</a></li>
                </ul>
            </div>

            <button class="btn btn-primary disabled" type="button">共${pageBean.rowCount}条记录</button>

            <c:if test="${pageBean.page==pageBean.pageCount }">
                <button class="btn btn-primary disabled" type="button">下一页</button>
            </c:if>
            <c:if test="${pageBean.page<pageBean.pageCount }">
                <button onclick="gotoPage(${pageBean.page+1},${pageBean.pageSize})" class="btn btn-primary"
                        type="button">下一页
                </button>
            </c:if>
            <button onclick="gotoPage(${pageBean.pageCount },${pageBean.pageSize})" class="btn btn-primary"
                    type="button">尾页
            </button>
        </div>
    </div>
</div>

<%@include file="../modal/selectemp.jsp" %>
<script type="text/javascript">
    function setempvalue(eid, empName) {
        $("#empid").val(eid);
        $("#empName").val(empName);
    }
</script>
</body>
<script type="text/javascript">
    function gotoPage(page, pageSize) {
        $("#page").val(page);
        $("#pageSize").val(pageSize);
        $("#seachform").submit();
    }

    function clearSearch() {
        $("#startDate").val("");
        $("#endDate").val("");
        $("#empid").val("");
        $("#empName").val("");

    }
</script>
</html>